package a51qindian.com.comprehensive.net;

import a51qindian.com.comprehensive.model.BaseModel;
import io.reactivex.Observer;
import io.reactivex.annotations.NonNull;

/**
 * Author: Li
 * Date: 2017/9/20 0020
 * Description:
 */

public abstract class SelectorObserver<T> implements Observer<T> {

    @Override
    public void onNext(@NonNull T t) {

        BaseModel baseModel= (BaseModel) t;
        if (baseModel.getCode() == 1) {
            onSuccess(t);
        } else {
            onErrorCodeInfo(baseModel.getCode(), baseModel.getInfo());
        }
    }

    @Override
    public void onComplete() {

    }

    protected abstract void onErrorCodeInfo(int code, String info);


    protected abstract void onSuccess(T t);
}
